#include <ctime>
#include <iostream>
using namespace std;

bool checkyear(int& year)
{
    if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0) return true;
    return false;
}

int main()
{
    int monthday;
    int arr[13];
    for (int i = 1; i <= 12; i++)
    {
        if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)
            monthday = 31;
        else monthday = 30;
        arr[i] = monthday;
    }
    int year, today;
    while (scanf("%d%d", &year, &today) != EOF)
    {
        if (checkyear(year)) monthday = 29;
        else if (!checkyear(year)) monthday = 28;
        arr[2] = monthday;


        for (int i = 1; i <= 12; i++)
        {
            today -= arr[i];
            if (today <= 0)
            {

                cout << year;
                if (i >= 10)
                    cout << "-" << i;
                else cout << "-0" << i;
                int day = arr[i] + today;
                if (day >= 10) cout << "-" << day << endl;
                else cout << "-0" << day << endl;
                break;
            }

        }

    }
    return 0;
}